#include "platfMsg_analy.h"

VEHICLE_ARGS_STR p_vehicleArgs = {0};
extern INSTALL_ARGS_STR p_installArgs;

INT32 platfStrend_handle(INT32 i, INT32 j, INT8 *strPin, INT8 *strPt)
{
	INT32 len = 0;

	if(i == j - 1)
	{
		memset(strPt, 0, strlen((const char *)strPt));
		len = strlen((const char *)strPin);
		memcpy(strPt, strPin, len);
	}
	else{
		len = split_platfMsg(strPin, strPt, ',');
	}
	return len;
}

//0x8A00 platform RSA public key
INT32 platf_RSA_key(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[4] = {0};
	UINT8 *phead = pOut;
	DWORD e;
	INT32 len = 0, cntLen = 0;

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	e = str_to_hex(pTmp);
	(*(UINT32 *)pOut) = e;
	pOut += 4;
	
	cntLen = strlen((const char *)pIn);
	memcpy(pOut, pIn, cntLen);
	pOut += cntLen;

	return (pOut-phead);
}

//0x8900 data down penetrate
INT32 data_down_penetrate(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[4] = {0};
	UINT8 *phead = pOut, type;
	INT32 len = 0, cntLen = 0;

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	type = str_to_hex(pTmp);
	*pOut++ = type;
	
	cntLen = strlen((const char *)pIn);
	memcpy(pOut, pIn, cntLen);
	E(" cnt: %s", pOut);
	pOut += cntLen;

	return (pOut-phead);
}

//0x8804 save media data upload cmd
INT32 start_tape_cmd(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[10] = {0};
	UINT8 *phead = pOut;
	UINT8 cmd, flag, frequency;
	UINT16 len, time;

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	cmd = str_to_hex(pTmp);
	*pOut++ = cmd;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	time = str_to_hex(pTmp);
	(*(UINT16 *)pOut) = htons(time);
	pOut += 2;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	flag = str_to_hex(pTmp);
	*pOut++ = flag;

	memset(pTmp, 0, sizeof(pTmp));
	len = strlen((const char *)pIn);
	memcpy(pTmp, pIn, len);
	frequency = str_to_hex(pTmp);
	*pOut++ = frequency;

	return (pOut-phead);
}

//0x8803 save media data upload cmd
INT32 save_medata_upCmd(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[20] = {0};
	UINT8 *phead = pOut;
	UINT8 type, id, code, flag;
	INT32 len;
	UINT8 time[6] = {0};

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	type = str_to_hex(pTmp);
	*pOut++ = type;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	id = str_to_hex(pTmp);
	*pOut++ = id;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	code = str_to_hex(pTmp);
	*pOut++ = code;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	simStr_convert_hex(pTmp, time);
	memcpy(pOut, time, 6);
	pOut += 6;

	memset(time, 0, sizeof(time));
	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	simStr_convert_hex(pTmp, time);
	memcpy(pOut, time, 6);
	pOut += 6;

	memset(pTmp, 0, sizeof(pTmp));
	len = strlen((const char *)pIn);
	memcpy(pTmp, pIn, len);
	flag = str_to_hex(pTmp);
	*pOut++ = flag;

	return (pOut-phead);
}

//0x8802 save media data search
INT32 save_media_data(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[13] = {0};	
	INT32 len, r;
	UINT8 *phead = pOut, type, id, code;
	UINT8 time[6] = {0};

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	type = str_to_hex(pTmp);
	*pOut++ = type;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	id = str_to_hex(pTmp);
	*pOut++ = id;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	code = str_to_hex(pTmp);
	*pOut++ = code;
	E(" code: %d", code);

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	simStr_convert_hex(pTmp, time);
	for(r = 0; r < 6; r++){
		fprintf(stdout, "%02x ", time[r]);
	}
	putchar('\n');
	memcpy(pOut, time, 6);
	pOut += 6;

	memset(time, 0, sizeof(time));
	memset(pTmp, 0, sizeof(pTmp));
	len = strlen((const char *)pIn);
	memcpy(pTmp, pIn, len);
	simStr_convert_hex(pTmp, time);
	for(r = 0; r < 6; r++){
		fprintf(stdout, "%02x ", time[r]);
	}
	putchar('\n');
	memcpy(pOut, time, 6);
	pOut += 6;

	return (pOut-phead);
}
//0x8801 camera take immediately
INT32 take_picture_immed(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[10] = {0};
	UINT8 *phead = pOut;
	INT32 len;
	TAKE_PICTURE_IMMED take;

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	take.passwId = str_to_hex(pTmp);
	*pOut++ = take.passwId;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	take.takeCmd = strtoul((const char *)pTmp, NULL, 16);
	(*(UINT16 *)pOut) = htons(take.takeCmd);
	pOut += 2;
	E(" take_cmd: %x", take.takeCmd);

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	take.takeGapVdTm = str_to_hex(pTmp);
	(*(UINT16 *)pOut) = htons(take.takeGapVdTm);
	pOut += 2;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	take.keepFlag = str_to_hex(pTmp);
	*pOut++ = take.keepFlag;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	take.disting = strtoul((const char *)pTmp, NULL, 16);
	*pOut++ = take.disting;
	E(" take_disting %x", take.disting);

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	take.picture.picQuality = str_to_hex(pTmp);
	*pOut++ = take.picture.picQuality;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	take.picture.light = str_to_hex(pTmp);
	*pOut++ = take.picture.light;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	take.picture.contrast = str_to_hex(pTmp);
	*pOut++ = take.picture.contrast;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	take.picture.saturation = str_to_hex(pTmp);
	*pOut++ = take.picture.saturation;

	memset(pTmp, 0, sizeof(pTmp));
	len = strlen((const char *)pIn);
	memcpy(pTmp, pIn, len);
	take.picture.chroma = str_to_hex(pTmp);
	*pOut++ = take.picture.chroma;
	E(" picture_chroma: %d", take.picture.chroma);

	return (pOut-phead);
}

//0x8800 media data upload reply
INT32 media_data_upRepy(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[10] = {0}, *p;
	UINT8 *phead = pOut, total = 0;
	INT32 len, ix;
	DWORD mediaId, msgId;	

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	mediaId = str_to_hex(pTmp);
	(*(UINT32 *)pOut) = htonl(mediaId);
	pOut += 4;
	E(" mediaId: %d", mediaId);

	p = memchr(pIn, ',', strlen((const char *)pIn));
	if(p == NULL){
		total = 0;
		*pOut++ = total;
		E(" total: %d", total);
	}
	else{
		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		total = str_to_hex(pTmp);
		*pOut++ = total;
		E(" total: %d", total);

		for(ix = 0; ix < total; ix++)
		{
			if(ix == total -1){
				memset(pTmp, 0, sizeof(pTmp));
				len = strlen((const char *)pIn);
				memcpy(pTmp, pIn, len);
				msgId = str_to_hex(pTmp);
				(*(UINT32 *)pOut) = htonl(msgId);
				pOut += 4;
				E(" msgId: %d", msgId);
			}
			else{
				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				msgId = str_to_hex(pTmp);
				(*(UINT32 *)pOut) = htonl(msgId);
				pOut += 4;
				E(" msgId: %d", msgId);
			}
		}
	}
	return (pOut-phead);
}

//0x8304 info service
INT32 info_service(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[4];
	UINT8 *phead = pOut, type;
	UINT16 len = 0, cntLen = 0;

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	type = str_to_hex(pTmp);
	*pOut++ = type;
	E(" type: %x", type);

	cntLen = strlen((const char *)pIn);
	(*(UINT16 *)pOut) = htons(cntLen);
	pOut += 2;
	E(" cntLen: %x", cntLen);

	memcpy(pOut, pIn, cntLen);
	E(" info_ctent: %s", pOut);

	return (pOut-phead);
}

//0x8303 info on demand
INT32 info_on_demand(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[4] = {0}, *p;
	UINT8 *phead = pOut, type, total;
	INT32 len, ix;
	UINT16 infoLen = 0;
	INFO_LIST info;

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = strlen((const char *)pIn);
	p = memchr(pIn, ',', len);
	if(p == NULL){
		memcpy(pTmp, pIn, len);
		type = str_to_hex(pTmp);
		*pOut++ = type;
		E(" type: %x", type);
	}
	else{
		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		type = str_to_hex(pTmp);
		*pOut++ = type;
		E(" type: %x", type);

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		total = str_to_hex(pTmp);
		*pOut++ = total;
		E(" total: %x", total);

		for(ix = 0; ix < total; ix++)
		{
			memset(&info, 0, sizeof(info));

			len = split_platfMsg(pIn, pTmp, ',');
			pIn += len;
			info.type = str_to_hex(pTmp);
			*pOut++ = info.type;
			E(" info_type: %x", info.type);

			if(ix == total -1){
				len = strlen((const char *)pIn);
				(*(UINT16 *)pOut)= htons(infoLen);
				pOut += 2;

				memcpy(info.name, pIn, len);
				E(" info_name: %s", info.name);
				memcpy(pOut, info.name, len);
				pOut += len;
			}
			else{
				len = split_platfMsg(pIn, (INT8 *)info.name, ',');
				E(" info_name: %s", info.name);
				pIn += len;
				len = strlen((const char *)info.name);
				(*(UINT16 *)pOut) = htons(infoLen);
				pOut += 2;

				memcpy(pOut, info.name, len);
				pOut += len;
			}
		}
	}
	return (pOut-phead);
}

//0x8401 set contact
INT32 set_contact(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[20] = {0};
	UINT8 *phead = pOut, type, total;
	INT32 ix, r, len = 0;
	CONTACT contact;

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	type = str_to_hex(pTmp);
	*pOut++ = type;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	total = str_to_hex(pTmp);
	*pOut++ = total;

	for(ix = 0; ix < total; ix++)
	{
		memset(&contact, 0, sizeof(contact));

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		contact.flags = str_to_hex(pTmp);
		*pOut++ = contact.flags;

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		simStr_convert_hex(pTmp, contact.sim);
		for(r = 0; r < 6; r++){
			fprintf(stdout, "%02x ", contact.sim[r]);
		}
		putchar('\n');

		*pOut++ = 6;
		memcpy(pOut, contact.sim, 6);
		pOut += 6;

		len = platfStrend_handle(ix, total, pIn, (INT8 *)contact.name);	
		pIn += len;

		E(" Name: %s", contact.name);
		len = strlen((const char *)contact.name);
		*pOut++ = len;
		memcpy(pOut, contact.name, len);
		pOut += len;
	}
	return (pOut-phead);
}
//0x8600 set circle region
INT32 setCircle_area(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[20] = {0};
	UINT8 *phead = pOut, attr, total;
	INT32 len, ix, r;
	CIRCLE_AREA circle;	

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	attr = str_to_hex(pTmp);
	*pOut++ = attr;
	E(" set_attr: %d", attr);

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	total = str_to_hex(pTmp);
	*pOut++ = total;
	E(" total: %d", total);

	for(ix = 0; ix < total; ix++)
	{
		memset(&circle, 0x0, sizeof(circle));

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		circle.id = str_to_hex(pTmp);
		E(" area_id: %d", circle.id);
		(*(UINT32 *)pOut) = htonl(circle.id);
		pOut += 4;

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		circle.attr = strtoul((const char *)pTmp, NULL, 16);
		E(" area_attr: %x", circle.attr);
		(*(UINT16 *)pOut) = htons(circle.attr);
		pOut += 2;

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		circle.latitude = strFloat_to_hex(pTmp, 6);
		E(" lat: %d", circle.latitude);
		(*(UINT32 *)pOut) = htonl(circle.latitude);
		pOut += 4;

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		circle.longitude = strFloat_to_hex(pTmp, 6);
		E(" lng: %d", circle.longitude);
		(*(UINT32 *)pOut) = htonl(circle.longitude);
		pOut += 4;

		if(ix == total - 1)
		{
			if(!IS_FLAG_BIT_SET(circle.attr, 1) && !IS_FLAG_BIT_SET(circle.attr, 0))
			{
				memset(pTmp, 0, sizeof(pTmp));
				len = strlen((const char *)pIn);
				memcpy(pTmp, pIn, len);
				circle.radius = str_to_hex(pTmp);
				E(" radius: %d", circle.radius);
				(*(UINT32 *)pOut) = htonl(circle.radius);
				pOut += 4;

			}
			else{
				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				circle.radius = str_to_hex(pTmp);
				E(" radius: %d", circle.radius);
				(*(UINT32 *)pOut) = htonl(circle.radius);
				pOut += 4;

				if(IS_FLAG_BIT_SET(circle.attr, 1) && IS_FLAG_BIT_SET(circle.attr, 0))
				{
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					simStr_convert_hex(pTmp, circle.start);
					for(r = 0; r < 6; r++){
						fprintf(stdout, "%02x", circle.start[r]);
					}
					putchar('\n');
					memcpy(pOut, circle.start, sizeof(circle.start));
					pOut += 6;

					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					simStr_convert_hex(pTmp, circle.end);
					for(r = 0; r < 6; r++){
						fprintf(stdout, "%02x", circle.end[r]);
					}
					putchar('\n');
					memcpy(pOut, circle.end, sizeof(circle.end));
					pOut += 6;

					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					circle.maxSpeed = str_to_hex(pTmp);
					E(" maxSpeed: %d", circle.maxSpeed);
					(*(UINT16 *)pOut) = htons(circle.maxSpeed);
					pOut += 2;

					memset(pTmp, 0, sizeof(pTmp));
					len = strlen((const char *)pIn);
					memcpy(pTmp, pIn, len);
					circle.overSpdTm = str_to_hex(pTmp);
					E(" overSpdTm: %d", circle.overSpdTm);
					*pOut++ = circle.overSpdTm;
				}
				else if(IS_FLAG_BIT_SET(circle.attr, 0))
				{
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					simStr_convert_hex(pTmp, circle.start);
					for(r = 0; r < 6; r++){
						fprintf(stdout, "%02x", circle.start[r]);
					}
					putchar('\n');
					memcpy(pOut, circle.start, sizeof(circle.start));
					pOut += 6;

					memset(pTmp, 0, sizeof(pTmp));
					len = strlen((const char *)pIn);
					memcpy(pTmp, pIn, len);
					simStr_convert_hex(pTmp, circle.end);
					for(r = 0; r < 6; r++){
						fprintf(stdout, "%02x", circle.end[r]);
					}
					putchar('\n');
					memcpy(pOut, circle.end, sizeof(circle.end));
					pOut += 6;

				}
				else if(IS_FLAG_BIT_SET(circle.attr, 1))
				{
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					circle.maxSpeed = str_to_hex(pTmp);
					E(" maxSpeed: %d", circle.maxSpeed);
					(*(UINT16 *)pOut) = htons(circle.maxSpeed);
					pOut += 2;

					memset(pTmp, 0, sizeof(pTmp));
					len = strlen((const char *)pIn);
					memcpy(pTmp, pIn, len);
					circle.overSpdTm = str_to_hex(pTmp);
					E(" overSpdTm: %d", circle.overSpdTm);
					*pOut++ = circle.overSpdTm;

				}
			}//end if 
		}//end if(ix == total))
		else{
			len = split_platfMsg(pIn, pTmp, ',');
			pIn += len;
			circle.radius = str_to_hex(pTmp);
			E(" radius: %d", circle.radius);
			(*(UINT32 *)pOut) = htonl(circle.radius);
			pOut += 4;

			if(IS_FLAG_BIT_SET(circle.attr, 0))
			{
				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				simStr_convert_hex(pTmp, circle.start);
				for(r = 0; r < 6; r++){
					fprintf(stdout, "%02x", circle.start[r]);
				}
				putchar('\n');
				memcpy(pOut, circle.start, sizeof(circle.start));
				pOut += 6;

				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				simStr_convert_hex(pTmp, circle.end);
				for(r = 0; r < 6; r++){
					fprintf(stdout, "%02x", circle.end[r]);
				}
				putchar('\n');
				memcpy(pOut, circle.end, sizeof(circle.end));
				pOut += 6;
			}

			if(IS_FLAG_BIT_SET(circle.attr, 1))
			{
				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				circle.maxSpeed = str_to_hex(pTmp);
				E(" maxSpeed: %d", circle.maxSpeed);
				(*(UINT16 *)pOut) = htons(circle.maxSpeed);
				pOut += 2;

				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				circle.overSpdTm = str_to_hex(pTmp);
				E(" overSpdTm: %d", circle.overSpdTm);
				*pOut++ = circle.overSpdTm;
			}
		}//end else
	}//end for

	return (pOut-phead);
}
//0x8602 set rect region
INT32 setRect_area(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[13] = {0};
	UINT8 *phead = pOut, attr, total;
	INT32 len, ix, r;
	RECT_AREA rect;	

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	attr = str_to_hex(pTmp);
	*pOut++ = attr;
	E(" set_attr: %d", attr);

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	total = str_to_hex(pTmp);
	*pOut++ = total;
	E(" total: %d", total);

	for(ix = 0; ix < total; ix++)
	{
		memset(&rect, 0x0, sizeof(rect));

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		rect.id = str_to_hex(pTmp);
		E(" area_id: %d", rect.id);
		(*(UINT32 *)pOut) = htonl(rect.id);
		pOut += 4;

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		rect.attr = strtoul((const char *)pTmp, NULL, 16);
		E(" area_attr: %x", rect.attr);
		(*(UINT16 *)pOut) = htons(rect.attr);
		pOut += 2;

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		rect.topLLat = strFloat_to_hex(pTmp, 6);
		E(" topLLat: %d", rect.topLLat);
		(*(UINT32 *)pOut) = htonl(rect.topLLat);
		pOut += 4;

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		rect.topLLon = strFloat_to_hex(pTmp, 6);
		E(" topLLon: %d", rect.topLLon);
		(*(UINT32 *)pOut) = htonl(rect.topLLon);
		pOut += 4;

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		rect.botRLat = strFloat_to_hex(pTmp, 6);
		E(" botRLat: %d", rect.botRLat);
		(*(UINT32 *)pOut) = htonl(rect.botRLat);
		pOut += 4;

		if(ix == total -1)
		{
			if(!IS_FLAG_BIT_SET(rect.attr, 1) && !IS_FLAG_BIT_SET(rect.attr, 0))
			{
				memset(pTmp, 0, sizeof(pTmp));
				len = strlen((const char *)pIn);
				memcpy(pTmp, pIn, len);
				rect.botRLon = strFloat_to_hex(pTmp, 6);
				E(" botRLon: %d", rect.botRLon);
				(*(UINT32 *)pOut) = htonl(rect.botRLon);
				pOut += 4;
			}
			else{
				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				rect.botRLon = strFloat_to_hex(pTmp, 6);
				E(" botRLon: %d", rect.botRLon);
				(*(UINT32 *)pOut) = htonl(rect.botRLon);
				pOut += 4;

				if(IS_FLAG_BIT_SET(rect.attr, 1) && IS_FLAG_BIT_SET(rect.attr, 0))
				{
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					simStr_convert_hex(pTmp, rect.start);
					for(r = 0; r < 6; r++){
						fprintf(stdout, "%02x", rect.start[r]);
					}
					putchar('\n');
					memcpy(pOut, rect.start, sizeof(rect.start));
					pOut += 6;

					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					simStr_convert_hex(pTmp, rect.end);
					for(r = 0; r < 6; r++){
						fprintf(stdout, "%02x", rect.end[r]);
					}
					putchar('\n');
					memcpy(pOut, rect.end, sizeof(rect.end));
					pOut += 6;

					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					rect.maxSpeed = str_to_hex(pTmp);
					E(" maxSpeed: %d", rect.maxSpeed);
					(*(UINT16 *)pOut) = htons(rect.maxSpeed);
					pOut += 2;

					memset(pTmp, 0, sizeof(pTmp));
					len = strlen((const char *)pIn);
					memcpy(pTmp, pIn, len);
					rect.overSpdTm = str_to_hex(pTmp);
					E(" overSpdTm: %d", rect.overSpdTm);
					*pOut++ = rect.overSpdTm;
				}
				else if(IS_FLAG_BIT_SET(rect.attr, 0))
				{
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					simStr_convert_hex(pTmp, rect.start);
					for(r = 0; r < 6; r++){
						fprintf(stdout, "%02x", rect.start[r]);
					}
					putchar('\n');
					memcpy(pOut, rect.start, sizeof(rect.start));
					pOut += 6;

					memset(pTmp, 0, sizeof(pTmp));
					len = strlen((const char *)pIn);
					memcpy(pTmp, pIn, len);
					simStr_convert_hex(pIn, rect.end);
					for(r = 0; r < 6; r++){
						fprintf(stdout, "%02x", rect.end[r]);
					}
					putchar('\n');
					memcpy(pOut, rect.end, sizeof(rect.end));
					pOut += 6;
				}
				else if(IS_FLAG_BIT_SET(rect.attr, 1))
				{
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					rect.maxSpeed = str_to_hex(pTmp);
					E(" maxSpeed: %d", rect.maxSpeed);
					(*(UINT16 *)pOut) = htons(rect.maxSpeed);
					pOut += 2;

					memset(pTmp, 0, sizeof(pTmp));
					len = strlen((const char *)pIn);
					memcpy(pTmp, pIn, len);
					rect.overSpdTm = str_to_hex(pTmp);
					E(" overSpdTm: %d", rect.overSpdTm);
					*pOut++ = rect.overSpdTm;

				}
			}//end if
		}//end if(ix == total)
		else{
			len = split_platfMsg(pIn, pTmp, ',');
			pIn += len;
			rect.botRLon = strFloat_to_hex(pTmp, 6);
			E(" botRLon: %d", rect.botRLon);
			(*(UINT32 *)pOut) = htonl(rect.botRLon);
			pOut += 4;

			if(IS_FLAG_BIT_SET(rect.attr, 0))
			{
				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				simStr_convert_hex(pTmp, rect.start);
				for(r = 0; r < 6; r++){
					fprintf(stdout, "%02x", rect.start[r]);
				}
				putchar('\n');
				memcpy(pOut, rect.start, sizeof(rect.start));
				pOut += 6;

				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				simStr_convert_hex(pTmp, rect.end);
				for(r = 0; r < 6; r++){
					fprintf(stdout, "%02x", rect.end[r]);
				}
				putchar('\n');
				memcpy(pOut, rect.end, sizeof(rect.end));
				pOut += 6;
			}
			if(IS_FLAG_BIT_SET(rect.attr, 1))
			{
				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				rect.maxSpeed = str_to_hex(pTmp);
				E(" maxSpeed: %d", rect.maxSpeed);
				(*(UINT16 *)pOut) = htons(rect.maxSpeed);
				pOut += 2;

				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				rect.overSpdTm = str_to_hex(pTmp);
				E(" overSpdTm: %d", rect.overSpdTm);
				*pOut++ = rect.overSpdTm;
			}
		}
	}

	return (pOut-phead);
}

//0x8604 set polygon region
INT32 setPolygon_area(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[20] = {0};
	UINT8 *phead = pOut;
	INT32 len, ix, r;
	POLYGON_AREA polygon = {0};	

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	polygon.id = str_to_hex(pTmp);
	E(" areaId: %x", polygon.id);
	(*(UINT32 *)pOut) = htonl(polygon.id);
	pOut += 4;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	polygon.attr = strtoul((const char *)pTmp, NULL, 16);
	E(" attr: %x", polygon.attr);
	(*(UINT16 *)pOut) = htons(polygon.attr);
	pOut += 2;

	if(IS_FLAG_BIT_SET(polygon.attr, 0))
	{
		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		simStr_convert_hex(pTmp, polygon.start);
		memcpy(pOut, polygon.start, sizeof(polygon.start));
		pOut += 6;

		for(r = 0; r < 6; r++){
			fprintf(stdout, "%02x ", polygon.start[r]);
		}
		putchar('\n');

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		simStr_convert_hex(pTmp, polygon.end);
		memcpy(pOut, polygon.end, sizeof(polygon.end));
		pOut += 6;
		for(r = 0; r < 6; r++){
			fprintf(stdout, "%02x ", polygon.end[r]);
		}
		putchar('\n');
	}
	if(IS_FLAG_BIT_SET(polygon.attr, 1))
	{
		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		polygon.maxSpeed = str_to_hex(pTmp);
		(*(UINT16 *)pOut) = htons(polygon.maxSpeed);
		pOut += 2;
		E(" maxSpeed: %d", polygon.maxSpeed);

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		polygon.overSpdTm = str_to_hex(pTmp);
		*pOut++ = polygon.overSpdTm;
		E(" overSpdTm: %d", polygon.overSpdTm);
	}

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	polygon.verTotal = str_to_hex(pTmp);
	E(" total: %d", polygon.verTotal);
	(*(UINT16 *)pOut) = htons(polygon.verTotal);
	pOut += 2;

	for(ix = 0; ix < polygon.verTotal; ix++)
	{
		memset(&polygon.ver, 0, sizeof(polygon.ver));

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		polygon.ver[ix].latitude = strFloat_to_hex(pTmp, 6);
		E(" lat: %d", polygon.ver[ix].latitude);
		(*(UINT32 *)pOut) = htonl(polygon.ver[ix].latitude);
		pOut += 4;

		len = platfStrend_handle(ix, polygon.verTotal, pIn, pTmp);	
		pIn += len;
		polygon.ver[ix].longitude = strFloat_to_hex(pTmp, 6);
		E(" lng: %d", polygon.ver[ix].longitude);
		(*(UINT32 *)pOut) = htonl(polygon.ver[ix].longitude);
		pOut += 4;	

	}
	return (pOut-phead);
}

//0x8606 set route
INT32 set_route(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[13] = {0}, *p;
	UINT8 *phead = pOut;
	INT32 len, ix, r;
	ROUTE route = {0};	

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	route.id = str_to_hex(pTmp);
	(*(UINT32 *)pOut) = htonl(route.id);
	pOut += 4;
	E(" route_id: %d", route.id);

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	route.attr = strtoul((const char *)pTmp, NULL, 16);
	(*(UINT16 *)pOut) = htons(route.attr);
	pOut += 2;
	E(" route_attr: %x", route.attr);

	if(IS_FLAG_BIT_SET(route.attr, 0))
	{
		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		simStr_convert_hex(pTmp, route.start);
		for(r = 0; r < 6; r++){
			fprintf(stdout, "%02x ", route.start[r]);
		}
		putchar('\n');
		memcpy(pOut, route.start, sizeof(route.start));
		pOut += 6;

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		simStr_convert_hex(pTmp, route.end);
		for(r = 0; r < 6; r++){
			fprintf(stdout, "%02x ", route.end[r]);
		}
		putchar('\n');
		memcpy(pOut, route.end, sizeof(route.end));
		pOut += 6;
	}

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	route.pntTotal = str_to_hex(pTmp);
	(*(UINT16 *)pOut) = htons(route.pntTotal);
	pOut += 2;
	E(" total: %d", route.pntTotal);

	for(ix = 0; ix < route.pntTotal; ix++)
	{
		memset(&route.pnt, 0, sizeof(route.pnt));

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		route.pnt[ix].pntId = str_to_hex(pTmp);
		(*(UINT32 *)pOut) = htonl(route.pnt[ix].pntId);
		pOut += 4;
		E(" pntId: %d", route.pnt[ix].pntId);

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		route.pnt[ix].roadId = str_to_hex(pTmp);
		(*(UINT32 *)pOut) = htonl(route.pnt[ix].roadId);
		pOut += 4;
		E(" roadId: %d", route.pnt[ix].roadId);

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		route.pnt[ix].latitude = strFloat_to_hex(pTmp, 6);
		(*(UINT32 *)pOut) = htonl(route.pnt[ix].latitude);
		pOut += 4;
		E(" lat: %d", route.pnt[ix].latitude);

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		route.pnt[ix].longitude = strFloat_to_hex(pTmp, 6);
		(*(UINT32 *)pOut) = htonl(route.pnt[ix].longitude);
		pOut += 4;	
		E(" lng: %d", route.pnt[ix].longitude);

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		route.pnt[ix].width = str_to_hex(pTmp);
		*pOut++ = route.pnt[ix].width;
		E(" width: %d", route.pnt[ix].width);

		p = memchr(pIn, ',', strlen((const char *)pIn));
		if(p == NULL){
			memset(pTmp, 0, sizeof(pTmp));
			memcpy(pTmp, pIn, strlen((const char *)pIn));
			route.pnt[ix].attr = strtoul((const char *)pTmp, NULL, 16);
			*pOut++ = route.pnt[ix].attr;
			E(" width_attr: %x", route.pnt[ix].attr);
		}
		else{
			len = split_platfMsg(pIn, pTmp, ',');
			pIn += len;
			route.pnt[ix].attr = strtoul((const char *)pTmp, NULL, 16);
			*pOut++ = route.pnt[ix].attr;
			E(" width_attr: %x", route.pnt[ix].attr);

			if(ix == route.pntTotal - 1)
			{
				if(IS_FLAG_BIT_SET(route.pnt[ix].attr, 0) && IS_FLAG_BIT_SET(route.pnt[ix].attr, 1))
				{
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					route.pnt[ix].maxDrvTm = str_to_hex(pTmp);
					(*(UINT16 *)pOut) = htons(route.pnt[ix].maxDrvTm);
					pOut += 2;
					E(" maxDrvTm: %d", route.pnt[ix].maxDrvTm);

					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					route.pnt[ix].minDrvTm = str_to_hex(pTmp);
					(*(UINT16 *)pOut) = htonl(route.pnt[ix].minDrvTm);
					pOut += 2;
					E(" minDrvTm: %d", route.pnt[ix].minDrvTm);

					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					route.pnt[ix].maxSpd = str_to_hex(pTmp);
					(*(UINT16 *)pOut) = htons(route.pnt[ix].maxSpd);
					pOut += 2;
					E(" maxSpd: %d", route.pnt[ix].maxSpd);

					memset(pTmp, 0, sizeof(pTmp));
					len = strlen((const char *)pIn);
					memcpy(pTmp, pIn, len);
					route.pnt[ix].overSpdTm = str_to_hex(pTmp);
					*pOut++ = route.pnt[ix].overSpdTm;
					E(" overSpdTm: %d", route.pnt[ix].overSpdTm);

				}
				else if(IS_FLAG_BIT_SET(route.pnt[ix].attr, 0))
				{	
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					route.pnt[ix].maxDrvTm = str_to_hex(pTmp);
					(*(UINT16 *)pOut) = htons(route.pnt[ix].maxDrvTm);
					pOut += 2;

					memset(pTmp, 0, sizeof(pTmp));
					len = strlen((const char *)pIn);
					memcpy(pTmp, pIn, len);
					route.pnt[ix].minDrvTm = str_to_hex(pTmp);
					(*(UINT16 *)pOut) = htonl(route.pnt[ix].minDrvTm);
					pOut += 2;
				}
				else if(IS_FLAG_BIT_SET(route.pnt[ix].attr, 1))
				{
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					route.pnt[ix].maxSpd = str_to_hex(pTmp);
					E(" maxSpd: %d", route.pnt[ix].maxSpd);
					(*(UINT16 *)pOut) = htons(route.pnt[ix].maxSpd);
					pOut += 2;

					memset(pTmp, 0, sizeof(pTmp));
					len = strlen((const char *)pIn);
					memcpy(pTmp, pIn, len);
					route.pnt[ix].overSpdTm = str_to_hex(pTmp);
					E(" overSpdTm: %d", route.pnt[ix].overSpdTm);
					*pOut++ = route.pnt[ix].overSpdTm;

				}
			}
			else{
				if(IS_FLAG_BIT_SET(route.pnt[ix].attr, 0))
				{	
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					route.pnt[ix].maxDrvTm = str_to_hex(pTmp);
					(*(UINT16 *)pOut) = htons(route.pnt[ix].maxDrvTm);
					pOut += 2;
					E(" maxDrvTm: %d", route.pnt[ix].maxDrvTm);

					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					route.pnt[ix].minDrvTm = str_to_hex(pTmp);
					(*(UINT16 *)pOut) = htonl(route.pnt[ix].minDrvTm);
					pOut += 2;
					E(" minDrvTm: %d", route.pnt[ix].minDrvTm);
				}
				if(IS_FLAG_BIT_SET(route.pnt[ix].attr, 1))
				{
					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					route.pnt[ix].maxSpd = str_to_hex(pTmp);
					(*(UINT16 *)pOut) = htons(route.pnt[ix].maxSpd);
					pOut += 2;
					E(" maxSpd: %d", route.pnt[ix].maxSpd);

					len = split_platfMsg(pIn, pTmp, ',');
					pIn += len;
					route.pnt[ix].overSpdTm = str_to_hex(pTmp);
					*pOut++ = route.pnt[ix].overSpdTm;
					E(" overSpdTm: %d", route.pnt[ix].overSpdTm);
				}

			}//end if(ix == total -1)
		}//end if(p == NULL)
	}//end for...

	return (pOut-phead);
}
//0x8601
INT32 delete_area_line(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[11] = {0}, *p;
	UINT8 *phead = pOut, num = 0;
	INT32 len, ix;
	DWORD id;	

	if(pIn == NULL || pOut == NULL)
		return -1;

	p = memchr(pIn, ',', strlen((const char *)pIn));
	if(p == NULL){
		num = 0;
		*pOut++ = num;
	}
	else{
		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		num = str_to_hex(pTmp);
		*pOut++ = num;
		E(" num: %d", num);	

		for(ix = 0; ix < num; ix++)
		{
			len = platfStrend_handle(ix, num, pIn, pTmp);	
			pIn += len;

			id = str_to_hex(pTmp);
			E(" id: %d", id);	
			(*(UINT32 *)pOut) = htonl(id);
			pOut += 4;
		}
	}
	return (pOut-phead);
}

//0x8202
INT32 temp_posTrack(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[11] = {0}, *p;
	UINT8 *phead = pOut;
	INT32 len;
	UINT16 interval;
	DWORD posVale;	

	if(pIn == NULL || pOut == NULL)
		return -1;

	p = memchr(pIn, ',', strlen((const char *)pIn));
	if(p == NULL){
		interval = 0;
		*pOut++ = interval;
	}	
	else{
		len = split_platfMsg(pIn, pTmp, ',');
		interval = str_to_hex(pTmp);
		E(" interval: %x", interval);
		(*(UINT16 *)pOut) = htons(interval);
		pOut += 2;

		memcpy(pTmp, pIn+len, strlen(pIn)-len);
		posVale = str_to_hex(pTmp);
		E(" posVale: %x", posVale);
		(*(UINT32 *)pOut) = htonl(posVale);
		pOut += 4;
	}

	return (pOut-phead);
}
//0x8301
INT32 event_set(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[4] = {0};
	UINT8 data[256] = {0}, *phead = pOut;
	UINT8 type, ix, total = 0;
	UINT8 id, len = 0;

	if(pIn == NULL || pOut == NULL)
		return -1;
	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	type = str_to_hex(pTmp);
	*pOut++ = type;
	E(" type: %x", type);	

	switch(type)
	{
		case 0:
			break;
		case 1:
		case 2:
		case 3:
			len = split_platfMsg(pIn, pTmp, ',');
			pIn += len;
			total = str_to_hex(pTmp);
			*pOut++ = total;
			E(" total: %x", total);
			
			for(ix = 0; ix < total; ix++)
			{
				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				id = str_to_hex(pTmp);
				*pOut++ = id;
				
				E(" id: %x", id);
				len = platfStrend_handle(ix, total, pIn, (INT8 *)data);
				E(" content: %s", data);
				pIn += len;
				*pOut++ = len;
				memcpy(pOut, data, len);
				pOut += len;

				id = 0;
				memset(data, 0, sizeof(data));
			}
			break;
		case 4:
			len = split_platfMsg(pIn, pTmp, ',');
			pIn += len;
			total = str_to_hex(pTmp);
			*pOut++ = total;
			E(" total4: %x", total);
			for(ix = 0; ix < total; ix++)
			{
				len = platfStrend_handle(ix, total, pIn, pTmp);
				pIn += len;

				id = str_to_hex(pTmp);
				*pOut++ = id;
				*pOut++ = 0;
				id = 0;
			}
			break;
		default:
			break;
	}
	return (pOut-phead);
}

//0x8302
INT32 question_send(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[4] = {0};
	UINT8 *phead = pOut;
	UINT8 flag, id, len = 0;
	UINT8 data[256] = {0};
	UINT16 cntLen = 0;

	if(pIn == NULL || pOut == NULL)
		return -1;
	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	flag = str_to_hex(pTmp);
	*pOut++ = flag;
	E(" flag: %x", flag);

	len = split_platfMsg(pIn, (INT8 *)data, ',');
	pIn += len;
	len = strlen((const char *)data);
	*pOut++ = len;
	memcpy(pOut, data, len);
	pOut += len;
	E(" len: %x", len);
	E(" data: %s", data);

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	id = str_to_hex(pTmp);
	*pOut++ = id;
	E(" id: %x", id);

	memset(data, 0, sizeof(data));
	len = strlen((const char *)pIn);
	memcpy(data, pIn, len);	
	(*(UINT16 *)pOut) = htons(cntLen);
	pOut += 2;

	memcpy(pOut, data, len);
	pOut += len;
	E(" data: %s", data);

	return (pOut-phead);
}

//0x8400
INT32 call_back(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[13] = {0};
	UINT8 *phead = pOut, ix;
	UINT8 flag, sim[6] = {0}, len = 0;

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	flag = str_to_hex(pTmp);
	*pOut++ = flag;

	memset(pTmp, 0, sizeof(pTmp));
	len = strlen((const char *)pIn);
	memcpy(pTmp, pIn, len);
	simStr_convert_hex(pTmp, sim);
	for(ix = 0; ix < 6; ix++){
		fprintf(stdout, "%02x ", sim[ix]);
	}
	putchar('\n');
	memcpy(pOut, sim, 6);
	pOut += 6;

	return (pOut-phead);
}

//0x8700
INT32 traver_record_cmd(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[4] = {0};
	UINT8 *phead = pOut;
	UINT8 cmd;

	if(pIn == NULL || pOut == NULL)
		return -1;

	memcpy(pTmp, pIn,strlen((const char *)pIn));
	cmd = strtoul((const char *)pTmp, NULL, 16);
	*pOut++ = cmd;
	E(" cmd: %x", cmd);
	
	return (pOut-phead);	
}

//0x8701
INT32 traver_record_down(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[30] = {0};
	UINT8 *phead = pOut;
	INT32 len, argLen, ix;
	TRAV_RECORD_DOWN trav_record = {0};

		if(pIn == NULL || pOut == NULL)
			return -1;

	len = split_platfMsg(pIn, pTmp, ',');
	pIn += len;
	trav_record.cmd = strtoul((const char *)pTmp, NULL, 16);
	*pOut++ = trav_record.cmd;

	memset(pTmp, 0, sizeof(pTmp));
	switch(trav_record.cmd)
	{
		case 0x81:
			len = split_platfMsg(pIn, pTmp, ',');
			pIn += len;

			trav_record.drvCode = str_to_hex(pTmp);
			E(" drvCode: %x", trav_record.drvCode);
			(*(UINT32 *)pOut) = trav_record.drvCode;
			pOut += 4;

			len = strlen((const char *)pIn);
			memcpy(trav_record.Idcard, pIn, len);
			argLen = strlen((const char *)trav_record.Idcard);
			E(" Idcard: %s", trav_record.Idcard);
			memcpy(pOut, trav_record.Idcard, argLen);
			pOut += argLen;
			break;
		case 0x82:
			len = split_platfMsg(pIn, (INT8 *)p_installArgs.vin, ',');
			pIn += len;
			argLen = strlen((const char *)p_installArgs.vin);
			E(" vin: %s", p_installArgs.vin);
			memcpy(pOut, p_installArgs.vin, argLen);
			pOut += argLen;
			
			len = split_platfMsg(pIn, (INT8 *)p_vehicleArgs.PlateNum, ',');
			pIn += len;
			argLen = strlen((const char *)p_vehicleArgs.PlateNum);
			E(" PlateNum: %s", p_vehicleArgs.PlateNum);
			memcpy(pOut, p_vehicleArgs.PlateNum, argLen);
			pOut += argLen;

			memset(pTmp, 0, sizeof(pTmp));
			len = strlen((const char *)pIn);
			memcpy(pTmp, pIn, len);			
			p_vehicleArgs.PlateColor = str_to_hex(pTmp);
			E(" PlateColor: %x", p_vehicleArgs.PlateColor);
			*pOut++ = p_vehicleArgs.PlateColor;
			break;
		case 0xC2:
			len = strlen((const char *)pIn);
			memcpy(pTmp, pIn, len);			
			simStr_convert_hex(pTmp, trav_record.time);
			for(ix = 0; ix < 6; ix++){
				fprintf(stdout, "%02x ", trav_record.time[ix]);
			}
			putchar('\n');
			memcpy(pOut, trav_record.time, 6);
			pOut += 6;
			break;
		case 0xC3:
			len = strlen((const char *)pIn);
			memcpy(pTmp, pIn, len);			
			trav_record.coefficient = str_to_hex(pTmp);
			E(" coefficient: %x", trav_record.coefficient);
			(*(UINT32 *)pOut) = trav_record.coefficient;
			pOut += 4;
			break;
		default:
			  break;
	}
	
	return (pOut-phead);
}

//0x8103
INT32 setTerm_args(INT8 *pIn, UINT8 *pOut)
{

	UINT32 argLen = 0, ix, len;	
	UINT8 *phead = pOut, argTal = 0;
	INT8 pTmp[13] = {0};
	DWORD argId;

	if(pIn == NULL || pOut == NULL)
		return -1;
	len = split_platfMsg(pIn, pTmp, ',');
	argTal = str_to_hex(pTmp);
	*pOut++ = argTal;
	pIn += len;

	E(" argTal: %d", argTal);

	memset(&p_installArgs, 0x0, sizeof(p_installArgs));
	for(ix = 0; ix < argTal; ix++)
	{
		memset(pTmp, 0, sizeof(pTmp));

		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		argId = strtoul(pTmp, NULL, 16);

		E(" argId: %x", argId);
		switch(argId)
		{
			case 0x0001:
				(*(UINT32 *)(pOut)) = htonl(0x0001);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.ack.beatInterval = str_to_hex(pTmp);
				E(" beatInterval: %x", p_installArgs.set.ack.beatInterval);

				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.ack.beatInterval);
				pOut += 4;
				break;
			case 0x0002:
				(*(UINT32 *)(pOut)) = htonl(0x0002);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.ack.tcpAckTimeout = str_to_hex(pTmp);
				E(" tcpAckTimeout: %x", p_installArgs.set.ack.tcpAckTimeout);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.ack.tcpAckTimeout);
				pOut += 4;
				break;
			case 0x0003:
				(*(UINT32 *)(pOut)) = htonl(0x0003);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.ack.smsRetransTimes = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.ack.smsRetransTimes);
				pOut += 4;
				break;		

			case 0x0004:
				(*(UINT32 *)(pOut)) = htonl(0x0004);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.ack.udpAckTimeout = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.ack.udpAckTimeout);
				pOut += 4;
				break;

			case 0x0005:
				(*(UINT32 *)(pOut)) = htonl(0x0005);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.ack.udpRetransTimes = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.ack.udpRetransTimes);
				pOut += 4;
				break;

			case 0x0006:
				(*(UINT32 *)(pOut)) = htonl(0x0006);
				pOut += 4;
				*pOut++ = 4;
				
				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.ack.smsAckTimeout = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.ack.smsAckTimeout);
				pOut += 4;
				break;

			case 0x0007:
				(*(UINT32 *)(pOut)) = htonl(0x0007);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.ack.smsRetransTimes = str_to_hex(pTmp);
				E(" smsRetransTimes: %x", p_installArgs.set.ack.smsRetransTimes);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.ack.smsRetransTimes);
				pOut += 4;
				break;
			case 0x0010:
				(*(UINT32 *)(pOut)) = htonl(0x0010);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, (INT8 *)p_installArgs.set.server.mainApn);
				pIn += len;
				E(" mainApn: %s", p_installArgs.set.server.mainApn);
				argLen = strlen((const char *)p_installArgs.set.server.mainApn);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.server.mainApn, argLen);
				pOut += argLen;
				break;
			case 0x0011:
				(*(UINT32 *)(pOut)) = htonl(0x0011);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, (INT8 *)p_installArgs.set.server.mainUsr);
				pIn += len;
				argLen = strlen((const char *)p_installArgs.set.server.mainUsr);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.server.mainUsr, argLen);
				pOut += argLen;
				break;
			case 0x0012:
				(*(UINT32 *)(pOut)) = htonl(0x0012);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, (INT8 *)p_installArgs.set.server.mainCode);
				pIn += len;
				argLen = strlen((const char *)p_installArgs.set.server.mainCode);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.server.mainUsr, argLen);
				pOut += argLen;
				break;
			case 0x0013:
				(*(UINT32 *)(pOut)) = htonl(0x0013);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, (INT8 *)p_installArgs.set.server.mainIp);
				pIn += len;
				argLen = strlen((const char *)p_installArgs.set.server.mainIp);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.server.mainIp, argLen);
				pOut += argLen;
				break;

			case 0x0014:
				(*(UINT32 *)(pOut)) = htonl(0x0014);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, (INT8 *)p_installArgs.set.server.backupApn);
				pIn += len;
				argLen = strlen((const char *)p_installArgs.set.server.backupApn);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.server.backupApn, argLen);
				pOut += argLen;
				break;

			case 0x0015:
				(*(UINT32 *)(pOut)) = htonl(0x0015);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, (INT8 *)p_installArgs.set.server.backupUsr);
				pIn += len;
				argLen = strlen((const char *)p_installArgs.set.server.backupUsr);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.server.backupUsr, argLen);
				pOut += argLen;
				break;

			case 0x0016:
				(*(UINT32 *)(pOut)) = htonl(0x0016);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, (INT8 *)p_installArgs.set.server.backupCode);
				pIn += len;
				argLen = strlen((const char *)p_installArgs.set.server.backupCode);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.server.backupCode, argLen);
				pOut += argLen;
				break;
			case 0x0017:
				(*(UINT32 *)(pOut)) = htonl(0x0017);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, (INT8 *)p_installArgs.set.server.backupIp);
				pIn += len;
				E(" backupIp: %s", p_installArgs.set.server.backupIp);
				argLen = strlen((const char *)p_installArgs.set.server.backupIp);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.server.backupIp, argLen);
				pOut += argLen;
				break;

			case 0x0018:
				(*(UINT32 *)(pOut)) = htonl(0x0018);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.server.tcpPort = str_to_hex(pTmp);
				E(" tcpPort: %x", p_installArgs.set.server.tcpPort);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.server.tcpPort);
				pOut += 4;
				break;

			case 0x0019:
				(*(UINT32 *)(pOut)) = htonl(0x0019);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.server.udpPort = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.server.udpPort);
				pOut += 4;
				break;

			case 0x0020:
				(*(UINT32 *)(pOut)) = htonl(0x0020);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.rptWay = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.rptWay);
				pOut += 4;
				break;
			case 0x0021:
				(*(UINT32 *)(pOut)) = htonl(0x0021);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.rptStatus = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.rptStatus);
				pOut += 4;
				break;
			case 0x0022:
				(*(UINT32 *)(pOut)) = htonl(0x0022);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.NoLogTmRpt = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.NoLogTmRpt);
				pOut += 4;
				break;

			case 0x0027:
				(*(UINT32 *)(pOut)) = htonl(0x0027);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.sleepTmRpt = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.sleepTmRpt);
				pOut += 4;
				break;

			case 0x0028:
				(*(UINT32 *)(pOut)) = htonl(0x0028);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.alarmTmRpt = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.alarmTmRpt);
				pOut += 4;
				break;
			case 0x0029:
				(*(UINT32 *)(pOut)) = htonl(0x0029);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.dftTmRpt = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.dftTmRpt);
				pOut += 4;
				break;
			case 0x002C:
				(*(UINT32 *)(pOut)) = htonl(0x002C);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.dftDisRpt = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.dftDisRpt);
				pOut += 4;
				break;
			case 0x002D:
				(*(UINT32 *)(pOut)) = htonl(0x002D);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.NoLogDisRpt = str_to_hex(pTmp);
				E(" NoLogDisRpt: %x", p_installArgs.set.report.NoLogDisRpt);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.NoLogDisRpt);
				pOut += 4;
				break;
			case 0x002E:
				(*(UINT32 *)(pOut)) = htonl(0x002E);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.sleepDisRpt = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.sleepDisRpt);
				pOut += 4;
				break;

			case 0x002F:
				(*(UINT32 *)(pOut)) = htonl(0x002F);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.alarmDisRpt = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.alarmDisRpt);
				pOut += 4;
				break;

			case 0x0030:
				(*(UINT32 *)(pOut)) = htonl(0x0030);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.report.angleRpt = str_to_hex(pTmp);
				E(" angleRpt: %x", p_installArgs.set.report.angleRpt);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.report.angleRpt);
				pOut += 4;
				break;
			case 0x0040:
				(*(UINT32 *)(pOut)) = htonl(0x0040);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				E(" centreTel: %s", pTmp);
				simStr_convert_hex(pTmp, p_installArgs.set.phone.centreTel);

				argLen = strlen((const char *)p_installArgs.set.phone.centreTel);
				*pOut++ = argLen;
				memcpy(pOut, p_installArgs.set.phone.centreTel, argLen);
				pOut += argLen;
				break;		

			case 0x0041:
				(*(UINT32 *)(pOut)) = htonl(0x0041);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				simStr_convert_hex(pTmp, p_installArgs.set.phone.resetTel);
				argLen = strlen((const char *)p_installArgs.set.phone.resetTel);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.phone.resetTel, argLen);
				pOut += argLen;
				break;	
			case 0x0042:
				(*(UINT32 *)(pOut)) = htonl(0x0042);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				simStr_convert_hex(pTmp, p_installArgs.set.phone.facSetTel);
				argLen = strlen((const char *)p_installArgs.set.phone.facSetTel);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.phone.facSetTel, argLen);
				pOut += argLen;
				break;	

			case 0x0043:
				(*(UINT32 *)(pOut)) = htonl(0x0043);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				simStr_convert_hex(pTmp, p_installArgs.set.phone.centreSmsTel);
				argLen = strlen((const char *)p_installArgs.set.phone.centreSmsTel);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.phone.centreSmsTel, argLen);
				pOut += argLen;
				break;	
			case 0x0044:
				(*(UINT32 *)(pOut)) = htonl(0x0043);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				E(" centreSmsAlarmTel: %s", pTmp);
				simStr_convert_hex(pTmp, p_installArgs.set.phone.centreSmsAlarmTel);
				argLen = strlen((const char *)p_installArgs.set.phone.centreSmsAlarmTel);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.phone.centreSmsAlarmTel, argLen);
				pOut += argLen;
				break;	
			case 0x0045:
				(*(UINT32 *)(pOut)) = htonl(0x0045);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.phone.answerWay = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.phone.answerWay);
				pOut += 4;
				break;
			case 0x0046:
				(*(UINT32 *)(pOut)) = htonl(0x0046);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.phone.MaxcallTmEach = strtoul((const char *)pTmp, NULL, 16);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.phone.MaxcallTmEach);
				pOut += 4;
				break;

			case 0x0047:
				(*(UINT32 *)(pOut)) = htonl(0x0047);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;

				p_installArgs.set.phone.MaxcallTmMon = strtoul((const char *)pTmp, NULL, 16);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.phone.MaxcallTmMon);
				pOut += 4;
				break;

			case 0x0048:
				(*(UINT32 *)(pOut)) = htonl(0x0048);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				simStr_convert_hex(pTmp, p_installArgs.set.phone.monitorTel);
				argLen = strlen((const char *)p_installArgs.set.phone.monitorTel);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.phone.monitorTel, argLen);
				pOut += argLen;
				break;	
			case 0x0049:
				(*(UINT32 *)(pOut)) = htonl(0x0049);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				simStr_convert_hex(pTmp, p_installArgs.set.phone.privilegeSmsTel);
				argLen = strlen((const char *)p_installArgs.set.phone.privilegeSmsTel);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.phone.privilegeSmsTel, argLen);
				pOut += argLen;
				break;	

			case 0x0050:
				(*(UINT32 *)(pOut)) = htonl(0x0050);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.alarmMask = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.alarmMask);
				pOut += 4;
				break;
			case 0x0051:
				(*(UINT32 *)(pOut)) = htonl(0x0051);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.alarmSmsFlag = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.alarmSmsFlag);
				pOut += 4;
				break;

			case 0x0052:
				(*(UINT32 *)(pOut)) = htonl(0x0052);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.alarmCmrFlag = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.alarmCmrFlag);
				pOut += 4;
				break;
			case 0x0053:
				(*(UINT32 *)(pOut)) = htonl(0x0053);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.alarmCmrSaveFlag = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.alarmCmrSaveFlag);
				pOut += 4;
				break;

			case 0x0054:
				(*(UINT32 *)(pOut)) = htonl(0x0054);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.alarmKeyFlag = str_to_hex(pTmp);
				E(" alarmKeyFlag: %x", p_installArgs.set.alarm.alarmKeyFlag);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.alarmKeyFlag);
				pOut += 4;
				break;

			case 0x0055:
				(*(UINT32 *)(pOut)) = htonl(0x0055);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.maxSpeed = str_to_hex(pTmp);
				E(" maxSpeed: %x", p_installArgs.set.alarm.maxSpeed);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.maxSpeed);
				pOut += 4;
				break;

			case 0x0056:
				(*(UINT32 *)(pOut)) = htonl(0x0056);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.overSpeedTm = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.overSpeedTm);
				pOut += 4;
				break;

			case 0x0057:
				(*(UINT32 *)(pOut)) = htonl(0x0057);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.conDrvTm = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.conDrvTm);
				pOut += 4;
				break;

			case 0x0058:
				(*(UINT32 *)(pOut)) = htonl(0x0058);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.totalDrvTm = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.totalDrvTm);
				pOut += 4;
				break;

			case 0x0059:
				(*(UINT32 *)(pOut)) = htonl(0x0059);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.minRestTm = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.minRestTm);
				pOut += 4;
				break;

			case 0x005A:
				(*(UINT32 *)(pOut)) = htonl(0x005A);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.alarm.MaxStopTm = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.alarm.MaxStopTm);
				pOut += 4;
				break;

			case 0x0070:
				(*(UINT32 *)(pOut)) = htonl(0x0070);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.pic.picQuality = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.pic.picQuality);
				pOut += 4;
				break;

			case 0x0071:
				(*(UINT32 *)(pOut)) = htonl(0x0071);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.pic.light = str_to_hex(pTmp);
				E(" light: %x", p_installArgs.set.pic.light);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.pic.light);
				pOut += 4;
				break;

			case 0x0072:
				(*(UINT32 *)(pOut)) = htonl(0x0072);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.pic.contrast = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.pic.contrast);
				pOut += 4;
				break;

			case 0x0073:
				(*(UINT32 *)(pOut)) = htonl(0x0073);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.pic.saturation = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.pic.saturation);
				pOut += 4;
				break;

			case 0x0074:
				(*(UINT32 *)(pOut)) = htonl(0x0074);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.pic.chroma = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.pic.chroma);
				pOut += 4;
				break;

			case 0x0080:
				(*(UINT32 *)(pOut)) = htonl(0x0080);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.vehicle.mileage = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.vehicle.mileage);
				pOut += 4;
				break;
			case 0x0081:
				(*(UINT32 *)(pOut)) = htonl(0x0081);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.vehicle.ProvinceId = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.vehicle.ProvinceId);
				pOut += 4;
				break;

			case 0x0082:
				(*(UINT32 *)(pOut)) = htonl(0x0082);
				pOut += 4;
				*pOut++ = 4;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.vehicle.CityId = str_to_hex(pTmp);
				(*(UINT32 *)(pOut)) = htonl(p_installArgs.set.vehicle.CityId);
				pOut += 4;
				break;
			case 0x0083:
				(*(UINT32 *)(pOut)) = htonl(0x0083);
				pOut += 4;

				len = platfStrend_handle(ix, argTal, pIn, (INT8 *)p_installArgs.set.vehicle.PlateNum);
				pIn += len;
				E(" PlateNum: %s", p_installArgs.set.vehicle.PlateNum);
				argLen = strlen((const char *)p_installArgs.set.vehicle.PlateNum);
				*pOut++ = argLen;

				memcpy(pOut, p_installArgs.set.vehicle.PlateNum, argLen);
				pOut += argLen;
				break;
			case 0x0084:
				(*(UINT32 *)(pOut)) = htonl(0x0084);
				pOut += 4;
				*pOut++ = 1;

				len = platfStrend_handle(ix, argTal, pIn, pTmp);
				pIn += len;
				p_installArgs.set.vehicle.PlateColor = str_to_hex(pTmp);
				E(" PlateColor: %x", p_installArgs.set.vehicle.PlateColor);
				*pOut++ = p_installArgs.set.vehicle.PlateColor;
				break;
			default:
				break;

		}//end switch...
	}//end for...

	return (pOut-phead);
}

//0x8300
INT32 txtInfo_send(INT8 *pIn, UINT8 *pOut)
{
	INT8 flag[4] = {0};
	UINT8 *phead = pOut, value;
	INT32 len;

	if(pIn == NULL || pOut == NULL)
		return -1;

	len = split_platfMsg(pIn, flag, ',');
	pIn += len;
	value = str_to_hex(flag);
	*pOut++ = value;
	E(" flag: %x", value);
	
	memcpy(pOut, (UINT8 *)pIn, strlen(pIn));	
	E(" txtInfo: %s", pOut);
	pOut += strlen(pIn);

	return (pOut-phead);
}

//0x8500
INT32 vehicle_control(INT8 *pIn, UINT8 *pOut)
{
	INT8 ctrlFlg[4] = {0};
	UINT8 *phead = pOut, value;

	if(pIn == NULL || pOut == NULL)
		return -1;
	memcpy(ctrlFlg, pIn, strlen(pIn));
	value = str_to_hex(ctrlFlg);
	*pOut++ = value;

	return (pOut-phead);
}

//0x8105
INT32 terminal_control(INT8 *pIn, UINT8 *pOut)
{
	INT8 pTmp[10] = {0}, cmd, *p;
	UINT8 *phead = pOut;
	INT32 len;
	CTRL_CMD_STR ctrCmd;

	if(pIn == NULL || pOut == NULL)
		return -1;

	memset(&ctrCmd, 0, sizeof(ctrCmd));	
	p = memchr(pIn, ',', strlen((const char *)pIn));
	if(p == NULL){
		memcpy(pTmp, pIn, strlen((const char *)pIn));
		cmd = strtoul((const char *)pTmp, NULL, 10);
		*pOut++ = cmd;
		E(" cmd: %d", cmd);
	}
	else{
		len = split_platfMsg(pIn, pTmp, ',');
		pIn += len;
		cmd = strtoul((const char *)pTmp, NULL, 10);
		*pOut++ = cmd;
		E(" cmd: %d", cmd);
		if(cmd == 1){

			len = split_platfMsg(pIn, (INT8 *)ctrCmd.url, ',');
			pIn += len;
			len = strlen((const char *)ctrCmd.url);
			memcpy(pOut, ctrCmd.url, len);
			pOut += len;
			E(" url: %s", ctrCmd.url);

			len = split_platfMsg(pIn, (INT8 *)ctrCmd.apn, ',');
			pIn += len;
			len = strlen((const char *)ctrCmd.apn);
			memcpy(pOut, ctrCmd.apn, len);
			pOut += len;
			E(" apn: %s", ctrCmd.apn);

			len = split_platfMsg(pIn, (INT8 *)ctrCmd.usr, ',');
			pIn += len;
			len = strlen((const char *)ctrCmd.usr);
			memcpy(pOut, ctrCmd.usr, len);
			pOut += len;
			E(" usr: %s", ctrCmd.usr);

			len = split_platfMsg(pIn, (INT8 *)ctrCmd.code, ',');
			pIn += len;
			len = strlen((const char *)ctrCmd.code);
			memcpy(pOut, ctrCmd.code, len);
			pOut += len;
			E(" code: %s", ctrCmd.code);

			len = split_platfMsg(pIn, (INT8 *)ctrCmd.ip, ',');
			pIn += len;
			len = strlen((const char *)ctrCmd.ip);
			memcpy(pOut, ctrCmd.ip, len);
			pOut += len;
			E(" ip: %s", ctrCmd.ip);

			len = split_platfMsg(pIn, pTmp, ',');
			pIn += len;
			ctrCmd.tcpPort = str_to_hex(pTmp);
			(*(UINT16 *)pOut) = htons(ctrCmd.tcpPort);
			pOut += 2;
			E(" tcpPort: %d", ctrCmd.tcpPort);

			len = split_platfMsg(pIn, pTmp, ',');
			pIn += len;
			ctrCmd.udpPort = str_to_hex(pTmp);
			(*(UINT16 *)pOut) = htons(ctrCmd.udpPort);
			pOut += 2;
			E(" udpPort: %d", ctrCmd.udpPort);

			len = split_platfMsg(pIn, (INT8 *)ctrCmd.mfrId, ',');
			pIn += len;
			len = strlen((const char *)ctrCmd.mfrId);
			memcpy(pOut, ctrCmd.mfrId, len);
			pOut += len;
			E(" mfrId: %s", ctrCmd.mfrId);

			len = split_platfMsg(pIn, (INT8 *)ctrCmd.hwVersion, ',');
			pIn += len;
			len = strlen((const char *)ctrCmd.hwVersion);
			memcpy(pOut, ctrCmd.hwVersion, len);
			pOut += len;
			E(" hwVersion: %s", ctrCmd.hwVersion);

			len = split_platfMsg(pIn, (INT8 *)ctrCmd.swVersion, ',');
			pIn += len;
			len = strlen((const char *)ctrCmd.swVersion);
			memcpy(pOut, ctrCmd.swVersion, len);
			pOut += len;
			E(" swVersion: %s", ctrCmd.swVersion);

			memset(pTmp, 0, sizeof(pTmp));
			memcpy(pTmp, pIn, strlen((const char *)pIn));
			ctrCmd.cntTm = str_to_hex(pTmp);
			(*(UINT16 *)pOut) = htons(ctrCmd.cntTm);
			pOut += 2;
			E(" cntTm: %d", ctrCmd.cntTm);

		}
		else if(cmd == 2){

			p = memchr(pIn, ',', strlen((const char *)pIn));
			if(p == NULL){
				ctrCmd.cnt = 1;
				*pOut++ = ctrCmd.cnt;
				E(" cnt: %d", ctrCmd.cnt);
			}
			else{	
				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				ctrCmd.cnt = str_to_hex(pTmp);
				*pOut++ = ctrCmd.cnt;
				E(" cnt: %d", ctrCmd.cnt);

				len = split_platfMsg(pIn, (INT8 *)ctrCmd.Akey, ',');
				pIn += len;
				len = strlen((const char *)ctrCmd.Akey);
				memcpy(pOut, ctrCmd.Akey, len);
				pOut += len;
				E(" Akey: %s", ctrCmd.Akey);

				len = split_platfMsg(pIn, (INT8 *)ctrCmd.apn, ',');
				pIn += len;
				len = strlen((const char *)ctrCmd.apn);
				memcpy(pOut, ctrCmd.apn, len);
				pOut += len;
				E(" apn: %s", ctrCmd.apn);

				len = split_platfMsg(pIn, (INT8 *)ctrCmd.usr, ',');
				pIn += len;
				len = strlen((const char *)ctrCmd.usr);
				memcpy(pOut, ctrCmd.usr, len);
				pOut += len;
				E(" usr: %s", ctrCmd.usr);

				len = split_platfMsg(pIn, (INT8 *)ctrCmd.code, ',');
				pIn += len;
				len = strlen((const char *)ctrCmd.code);
				memcpy(pOut, ctrCmd.code, len);
				pOut += len;
				E(" code: %s", ctrCmd.code);

				len = split_platfMsg(pIn, (INT8 *)ctrCmd.ip, ',');
				pIn += len;
				len = strlen((const char *)ctrCmd.ip);
				memcpy(pOut, ctrCmd.ip, len);
				pOut += len;
				E(" ip: %s", ctrCmd.ip);

				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				ctrCmd.tcpPort = str_to_hex(pTmp);
				(*(UINT16 *)pOut) = htons(ctrCmd.tcpPort);
				pOut += 2;
				E(" tcpPort: %d", ctrCmd.tcpPort);

				len = split_platfMsg(pIn, pTmp, ',');
				pIn += len;
				ctrCmd.udpPort = str_to_hex(pTmp);
				(*(UINT16 *)pOut) = htons(ctrCmd.udpPort);
				pOut += 2;
				E(" udpPort: %d", ctrCmd.udpPort);

				memset(pTmp, 0, sizeof(pTmp));
				memcpy(pTmp, pIn, strlen((const char *)pIn));
				ctrCmd.cntTm = str_to_hex(pTmp);
				(*(UINT16 *)pOut) = htons(ctrCmd.cntTm);
				pOut += 2;
				E(" cntTm: %d", ctrCmd.cntTm);
			}
		}
	}

	return (pOut-phead);
}
